﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;

namespace RubricaSentimentale.Model
{
    [CollectionDataContract]
    public class FormattedList<T> : ObservableCollection<T>
    {
        
        public string intestazione = "";
        [DataMember]
        public string Intestazione {
            get { return intestazione; }
            set 
            {
                intestazione = value;
            }
        }

        Button back = new Button();
        Span coll = new Span();
        InlineUIContainer cont = new InlineUIContainer();
        public delegate void BackTapped();
        BackTapped backTap;

        public FormattedList():base()
        {
            back.Content = "<- Back";
            back.Tap += new EventHandler<GestureEventArgs>(back_Tap);
            cont.Child = back;
        }

        void back_Tap(object sender, GestureEventArgs e)
        {
            backTap();
        }

        public void GetFormatted(InlineCollection coll)
        {
            coll.Clear();
            //coll.Add(cont);
            coll.Add(new LineBreak());
            Run tmp=new Run();
            tmp.Text=Intestazione;
            tmp.FontSize = 24;
            tmp.FontWeight = FontWeights.Bold;
            coll.Add(tmp);
            coll.Add(new LineBreak());
            for (int i = 0; i < this.Count; i++)
            {
                tmp=new Run();
                tmp.FontSize=20;
                tmp.Text=this[i].ToString();
                coll.Add(tmp);
                coll.Add(new LineBreak());
            }
            
        }

        public override string ToString()
        {

            string str = Intestazione;
            for (int i = 0; i < this.Count; i++)
            {
                str +="\t"+ this[i].ToString();
            }

            return str;
            
        }
    }
}
